﻿@model QueryCriteriaModel
@{
    var clientValidationEnabled = Html.ViewContext.ClientValidationEnabled;
    Html.ViewContext.ClientValidationEnabled = false;
}
<div class="row form-inline">

    @foreach (var group in Model.GroupFilters)
    {
        using (var filterHtml = Html.GetModelHtmlHelper(Model.QueryModelMetadata))
        {
            foreach (var filter in group.OrderByDescending(f => f.FilterOperation))
            {
                <div class="form-group col-xs-4">
                    @if (group.Count() == 2 && filter.FilterOperation == FilterOperation.LeEq)
                    {
                        <span>~</span>
                    }
                    else
                    {
                        @Html.Label(Html.GetExpressionText(m => m.Filters[Model.FilterIndex(group.First())].FilterValue), Model.FilterCollection.GetFilterModelMetadata(group.Key).DisplayName)
                    }
                    @Html.HiddenFor(m => m.Filters[Model.FilterIndex(filter)].FilterName)
                    @Html.HiddenFor(m => m.Filters[Model.FilterIndex(filter)].FilterOperation)
                    @filterHtml.Editor(group.Key, null,
                        Html.GetExpressionText(m => m.Filters[Model.FilterIndexAndSetValue(filter)].FilterValue), new { htmlAttributes = new { @class = "form-control" } })
                </div>
            }
        }
    }
</div>

@for (int i = 0; i < Model.Orders.Count; i++)
{
    @Html.HiddenFor(m => m.Orders[i].OrderName)
    @Html.HiddenFor(m => m.Orders[i].OrderAscending)
}
@{    Html.ViewContext.ClientValidationEnabled = clientValidationEnabled;}